package com.woniu.outpatient.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.woniu.outpatient.domain.Registrationtype;
import com.woniu.outpatient.service.IRegistrationtypeService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 就诊类型表Controller
 * 
 * @author wolf-six
 * @date 2023-02-15
 */
@RestController
@RequestMapping("/registrationtype")
public class RegistrationtypeController extends BaseController
{
    @Autowired
    private IRegistrationtypeService registrationtypeService;

    /**
     * 查询就诊类型表列表
     */
    @RequiresPermissions("outpatient:registrationtype:list")
    @GetMapping("/list")
    public TableDataInfo list(Registrationtype registrationtype)
    {
        startPage();
        List<Registrationtype> list = registrationtypeService.selectRegistrationtypeList(registrationtype);
        return getDataTable(list);
    }

    /**
     * 导出就诊类型表列表
     */
    @RequiresPermissions("outpatient:registrationtype:export")
    @Log(title = "就诊类型表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Registrationtype registrationtype)
    {
        List<Registrationtype> list = registrationtypeService.selectRegistrationtypeList(registrationtype);
        ExcelUtil<Registrationtype> util = new ExcelUtil<Registrationtype>(Registrationtype.class);
        util.exportExcel(response, list, "就诊类型表数据");
    }

    /**
     * 获取就诊类型表详细信息
     */
    @RequiresPermissions("outpatient:registrationtype:query")
    @GetMapping(value = "/{registrationtypeId}")
    public AjaxResult getInfo(@PathVariable("registrationtypeId") Long registrationtypeId)
    {
        return success(registrationtypeService.selectRegistrationtypeByRegistrationtypeId(registrationtypeId));
    }

    /**
     * 新增就诊类型表
     */
    @RequiresPermissions("outpatient:registrationtype:add")
    @Log(title = "就诊类型表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Registrationtype registrationtype)
    {
        return toAjax(registrationtypeService.insertRegistrationtype(registrationtype));
    }

    /**
     * 修改就诊类型表
     */
    @RequiresPermissions("outpatient:registrationtype:edit")
    @Log(title = "就诊类型表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Registrationtype registrationtype)
    {
        return toAjax(registrationtypeService.updateRegistrationtype(registrationtype));
    }

    /**
     * 删除就诊类型表
     */
    @RequiresPermissions("outpatient:registrationtype:remove")
    @Log(title = "就诊类型表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{registrationtypeIds}")
    public AjaxResult remove(@PathVariable Long[] registrationtypeIds)
    {
        return toAjax(registrationtypeService.deleteRegistrationtypeByRegistrationtypeIds(registrationtypeIds));
    }
}
